package com.storydo.file.share.rest;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.storydo.file.share.base.controller.BaseController;


@Controller
@RequestMapping("/auth")
public class AuthController extends BaseController {

	
	public static final String AUTH_KEY = "AuthKey";
	
	public static String CHECK_CODE = "";
	
	@RequestMapping("")
	public Object index() {
		return "auth";
	}
	
	@ResponseBody
	@RequestMapping(value = "/code", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public Object checkCode(String code, HttpSession session) {
		if (CHECK_CODE.equals(code)) {
			session.setAttribute(AUTH_KEY, AUTH_KEY);
			return success();
		}
		return error("验证码错误!");
	}
}
